/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.notaria.guerrasalas.be;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "DETALLE_CLIENTE_ACTO_JURIDICO")
public class DetalleClienteActoJuridico implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetalleClienteActoJuridicoPK detalleClienteActoJuridicoPK;
    @Enumerated
    @Basic(optional = false)
    @Column(name = "PARTICIPACION", nullable = false)
    private Participacion participacion;
    @JoinColumn(name = "FID_ACTO_JURIDICO", referencedColumnName = "ID_ACTO_JURIDICO", nullable = false, insertable = true, updatable = true)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ActoJuridicoConParticipantes actoJuridicoConParticipantes;
    @JoinColumn(name = "FID_CLIENTE", referencedColumnName = "ID_PERSONA", nullable = false, insertable = true, updatable = true)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Cliente cliente;
    @JoinColumn(name = "FID_CLIENTE_EXTRA", referencedColumnName = "ID_PERSONA")
    @ManyToOne(fetch = FetchType.LAZY)
    private Cliente clienteExtra;

    public DetalleClienteActoJuridico() {
        this.detalleClienteActoJuridicoPK = new DetalleClienteActoJuridicoPK();
    }

    public DetalleClienteActoJuridico(DetalleClienteActoJuridicoPK detalleClienteActoJuridicoPK) {
        this.detalleClienteActoJuridicoPK = detalleClienteActoJuridicoPK;
    }

    public ActoJuridicoConParticipantes getActoJuridicoConParticipantes() {
        return actoJuridicoConParticipantes;
    }

    public void setActoJuridicoConParticipantes(ActoJuridicoConParticipantes actoJuridicoConParticipantes) {
        this.actoJuridicoConParticipantes = actoJuridicoConParticipantes;
        this.detalleClienteActoJuridicoPK.setFidActoJuridico(actoJuridicoConParticipantes.getIdActoJuridico());
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
        this.detalleClienteActoJuridicoPK.setFidCliente(cliente.getIdPersona());
    }

    public Cliente getClienteExtra() {
        return clienteExtra;
    }

    public void setClienteExtra(Cliente clienteExtra) {
        this.clienteExtra = clienteExtra;
    }

    public DetalleClienteActoJuridicoPK getDetalleClienteActoJuridicoPK() {
        return detalleClienteActoJuridicoPK;
    }

    public void setDetalleClienteActoJuridicoPK(DetalleClienteActoJuridicoPK detalleClienteActoJuridicoPK) {
        this.detalleClienteActoJuridicoPK = detalleClienteActoJuridicoPK;
    }

    public Participacion getParticipacion() {
        return participacion;
    }

    public void setParticipacion(Participacion participacion) {
        this.participacion = participacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detalleClienteActoJuridicoPK != null ? detalleClienteActoJuridicoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleClienteActoJuridico)) {
            return false;
        }
        DetalleClienteActoJuridico other = (DetalleClienteActoJuridico) object;
        if ((this.detalleClienteActoJuridicoPK == null && other.detalleClienteActoJuridicoPK != null) || (this.detalleClienteActoJuridicoPK != null && !this.detalleClienteActoJuridicoPK.equals(other.detalleClienteActoJuridicoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return detalleClienteActoJuridicoPK.toString();
    }
}
